package config

import (
	"github.com/gookit/config/v2"
	"github.com/gookit/config/v2/yaml"
)

const ConfigFile = "/etc/lark/Default.yaml"

type FeishuStruct struct {
	AppId    string `mapstructure:"app_id"`
	Password string `mapstructure:"password"`
	ChatRoom string `mapstructure:"chat_room"`
	TokenUrl string `mapstructure:"token_url"`
	MsgUrl   string `mapstructure:"msg_url"`
	GroupUrl string `mapstructure:"group_url"`
}

type SettingsStruct struct {
	Feishu FeishuStruct `mapstructure:"feishu"`
}

var Settings SettingsStruct

func init() {
	config.WithOptions(config.ParseEnv)
	config.AddDriver(yaml.Driver)
	err := config.LoadFiles(ConfigFile)
	if err != nil {
		panic(err)
	}

	err = config.BindStruct("", &Settings)
	if err != nil {
		panic(err)
	}
}
